package util;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;


public class SqlSessionUtil {

    public static SqlSession getsqlsession(){
        SqlSession sqlSession=null;
        try{
            InputStream resourceAsStream = Resources.getResourceAsStream("mybatisconfig.xml");
            SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(resourceAsStream);
       sqlSession = sqlSessionFactory.openSession(true);
        }catch (Exception e){e.printStackTrace();}
        return sqlSession;
    };
}
